<?php

function Success($message = 'ok', $data = [], $code = 0, $statusCode = 200)
{
    $res = [
        'code' => $code,
        'message' => $message,
        'result' => $data,
    ];
    return response()->json($res, $statusCode);
}

function Error($message = 'error', $code = -1,  $data = [], $statusCode = 200)
{
    $res = [
        'code' => $code,
        'message' => $message,
        'result' => $data,
    ];
    return response()->json($res, $statusCode);
}

/**
 * 生成取件码
 * @param int $length
 * @return string
 */
function GenerateOutCode($location, $num)
{
    if ($num < 10){
        $num = '0' .$num;
    }
    $day = date('d',time());
    $out_code = $location . '-' .$day. $num;
    return $out_code;
}

